<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of adm
 *
 * @author dmitry
 */
class Controller_Adm extends Controller_Action {
    
    function index() 
    {
        $this->registry->get('view')->show('adm') ;
    }
    function addCategory()
    {
        $this->registry->get('view')->set('param', 'addCategory') ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function setMenu()
    {
        $this->registry->get('view')->set('param', 'setMenu') ;
        $this->registry->get('view')->set('visible', $_POST['visible']) ;
        $this->registry->get('view')->set('name', $_POST['menuname']) ;
        $this->registry->get('view')->set('description', $_POST['description']) ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function setCategory()
    {
        $this->registry->get('view')->set('param', 'setCategory') ;
        $this->registry->get('view')->set('menuID', $_POST['menuID']) ;
        $this->registry->get('view')->set('visible', $_POST['visible']) ;
        $this->registry->get('view')->set('name', $_POST['categoryname']) ;
        $this->registry->get('view')->set('description', $_POST['description']) ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function addGoods()
    {
        $this->registry->get('view')->set('param', 'addGoods') ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function setGoods()
    {
        for($i=0;$i<$_POST['propertycount'];$i++)
        {
            $property[$_POST['property_' . $i]] = $_POST[$i] ;
            unset ($_POST['property_' . $i]) ;
            unset ($_POST[$i]) ;
        }
        foreach ($_POST as $key => $value)
        {
            
            $insert[$key] = $value ;
        }

        $this->registry->get('view')->set('param', 'setGoods') ;
        $this->registry->get('view')->set('insert', $insert) ;
        $this->registry->get('view')->set('property', $property) ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function showAllGoods()
    {
        $this->registry->get('view')->set('param', 'allgoods') ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function showallcategories()
    {
        $this->registry->get('view')->set('param', 'allcategories') ;
        $this->registry->get('view')->show('adm') ;
    }

    function delCategory($id)
    {
        $this->registry->get('view')->set('param', 'delcategory') ;
        $this->registry->get('view')->set('insert', $id) ;
        $this->registry->get('view')->show('adm') ;
    }

    function delGoods($id)
    {
        $this->registry->get('view')->set('param', 'delgoods') ;
        $this->registry->get('view')->set('insert', $id) ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function showAllUsers()
    {
        $this->registry->get('view')->set('param', 'allusers') ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function editUser($id)
    {
        $this->registry->get('view')->set('param', 'edituser') ;
        $this->registry->get('view')->set('insert', $id) ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function setUser($id)
    {
        $this->registry->get('view')->set('property', $_POST['groupID']) ;
        $this->registry->get('view')->set('param', 'setuser') ;
        $this->registry->get('view')->set('insert', $id) ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function showProperties()
    {
        $this->registry->get('view')->set('param', 'showallproperties') ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function setProperty()
    {
        if($_POST['name'] === '') 
        { 
          echo 'Введіть назву!' ;
        } else {
            $this->registry->get('view')->set('param', 'setproperty') ;
            $this->registry->get('view')->set('insert', $_POST['name']) ;
            $this->registry->get('view')->show('adm') ;
        }
    }
    
    function delProperty($id)
    {
            $this->registry->get('view')->set('param', 'delproperty') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function showOrders()
    {
        $this->registry->get('view')->set('param', 'showorders') ;
        $this->registry->get('view')->show('adm') ;
    }
    
    function showOrder($id)
    {
            $this->registry->get('view')->set('param', 'showorder') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function editComment($id)
    {
            $this->registry->get('view')->set('param', 'editcomment') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function setComment($id)
    {
            $this->registry->get('view')->set('param', 'setcomment') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->set('property', $_POST['content']) ;
            $this->registry->get('view')->set('name', $_POST['product']) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function delComment($id)
    {
            $this->registry->get('view')->set('param', 'delcomment') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->set('name', $_POST['product']) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function status($id)
    {
            $this->registry->get('view')->set('param', 'status') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function editCategory($id)
    {
            $this->registry->get('view')->set('param', 'editcategory') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function setEditCategory($id)
    {
            $this->registry->get('view')->set('param', 'seteditcategory') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->set('name', $_POST['name']) ;
            $this->registry->get('view')->set('description', $_POST['description']) ;
            $this->registry->get('view')->set('menuID', $_POST['menuID']) ;
            $this->registry->get('view')->set('visible', $_POST['visible']) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function editGoods($id)
    {
            $this->registry->get('view')->set('param', 'editgoods') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
    
    function delProductProperty($id)
    {
            $this->registry->get('view')->set('param', 'delproductproperty') ;
            $this->registry->get('view')->set('insert', $id) ;
            $this->registry->get('view')->show('adm') ;
    }
}

?>
